package com.cda.mall.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cda.mall.entity.IndexImg;
import com.cda.mall.dao.IndexImgMapper;
import com.cda.mall.service.IIndexImgService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cda.mall.vo.ResStatus;
import com.cda.mall.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 轮播图  服务实现类
 * </p>
 *
 * @author cda
 * @since 2021-11-13
 */
@Service
public class IndexImgServiceImpl extends ServiceImpl<IndexImgMapper, IndexImg> implements IIndexImgService {

    @Autowired
    private IndexImgMapper indexImgMapper;

    @Override
    public ResultVO listIndexImgs() {
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.orderBy(true,true,"seq")
                .eq("status",1);
        List<IndexImg> list = indexImgMapper.selectList(wrapper);
        if (list.size()==0){
            return new ResultVO(ResStatus.NO,"fail",null);
        }else {
            return new ResultVO(ResStatus.OK,"success",list);
        }
    }
}
